<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改薪资管理')" />
            <th:block th:include="include :: datetimepicker-css" />
</head>
<style>
    .jltable{
        margin: auto;
    }
    .jltable th,td{
        min-height: 40px;
        min-width: 50px;
        border: 1px solid #eee;
        padding: 10px;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-xzgl-edit" th:object="${lwpqXzgl}">
        <h4 class="form-header h4">薪资管理信息</h4>
        <table class="jltable">
            <tbody>
                <input name="id" th:field="*{id}" type="hidden">
                <tr>
                    <td><label class="control-label">姓名：</label></td>
                    <td>
                        <input th:field="*{name}"  name="name" class="form-control" type="text" required>
                    </td>
                    <td> </td>
                    <td><label class="control-label">身份证：</label></td>
                    <td><input th:field="*{sfzh}"  name="sfzh" class="form-control" type="text"></td>
                </tr>

                <tr>
                    <td><label class="control-label">工号：</label></td>
                    <td><input th:field="*{gh}"  name="gh" class="form-control" type="text"></td>
                    <td></td>
                    <td><label class="control-label">员工分类：</label></td>
                    <td>
                        <select name="ygfl" class="form-control" th:with="type=${@dict.getType('lwpq_ygfl')}">
                            <option th:field="*{ygfl}" n th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label class="control-label">用工单位：</label></td>
                    <td><input th:field="*{ygdw}"  name="ygdw" class="form-control" type="text"></td>
                    <td></td>
                    <td><label class="control-label">基本工资：</label></td>
                    <td><input th:field="*{jbgz}"  name="jbgz" class="form-control" type="text"></td>
                </tr>

                <tr>
                    <td><label class="control-label">税费扣除：</label></td>
                    <td><input th:field="*{sfkc}"  name="sfkc" class="form-control" type="text"></td>
                    <td></td>
                    <td><label class="control-label">发放日期：</label></td>
                    <td>
                        <div class="input-group date">
                            <input th:value="${#dates.format(lwpqXzgl.ffrq, 'yyyy-MM-dd')}" name="ffrq" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td></td><td></td> <td></td>
                    <td><label class="control-label">发放方式：</label></td>
                    <td>
                        <select name="ffsf" class="form-control" th:with="type=${@dict.getType('lwpq_gzfffs')}">
                            <option th:field="*{ffsf}" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label class="control-label">备注：</label></td>
                    <td colspan="4"><textarea th:field="*{bz}" name="bz" class="form-control"></textarea></td>
                </tr>
            </tbody>
        </table>

        <h4 class="form-header h4" style="margin-top: 20px">月薪管理信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>

        <h4 class="form-header h4" style="margin-top: 20px">日薪管理信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <button type="button" class="btn btn-white btn-sm" onclick="addColumn_1()"><i class="fa fa-plus"> 增加</i></button>
                <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table-1"></table>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
        <th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "lwpq/xzgl";
    $("#form-xzgl-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-xzgl-edit').serialize());
        }
    }

            $("input[name='ffrq']").datetimepicker({
                format: "yyyy-mm-dd",
                minView: "month",
                autoclose: true
            });

    $(function() {
            var options = {
                data: [[${lwpqXzgl.lwpqYxList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
            columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                        var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                        return columnIndex + $.table.serialNumber(index);
                    }
                },
                    {
                        field: 'ffrq',
                        align: 'center',
                        title: '发放日期',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='date' name='lwpqYxList[%s].ffrq' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'jbgz',
                        align: 'center',
                        title: '基本工资',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].jbgz' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'jxgz',
                        align: 'center',
                        title: '绩效工资',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].jxgz' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'sbjf',
                        align: 'center',
                        title: '社保缴费',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].sbjf' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'jbf',
                        align: 'center',
                        title: '加班费',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].jbf' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'sfkc',
                        align: 'center',
                        title: '税费扣除',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].sfkc' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'jl',
                        align: 'center',
                        title: '奖励',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].jl' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'yxhj',
                        align: 'center',
                        title: '月薪合计',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].yxhj' value='%s'>", index, value);
                            return html;
                        }
                        },
                    {
                        field: 'yxsf',
                        align: 'center',
                        title: '月薪实发',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqYxList[%s].yxsf' value='%s'>", index, value);
                            return html;
                        }

            }]
        };
        $.table.init(options);
        });
    $(function() {
        var options = {
            id:"bootstrap-table-1",
            data: [[${lwpqXzgl.lwpqSxList}]],
            pagination: false,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            sidePagination: "client",
            columns: [{
                checkbox: true
            },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                        var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                        return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'ffrq',
                    align: 'center',
                    title: '发放日期',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='date' name='lwpqSxList[%s].ffrq' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'sx',
                    align: 'center',
                    title: '时薪',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].sx' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'gs',
                    align: 'center',
                    title: '工时',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].gs' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'qtxc',
                    align: 'center',
                    title: '其他薪酬',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].qtxc' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'sfkc',
                    align: 'center',
                    title: '税费扣除',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].sfkc' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'jl',
                    align: 'center',
                    title: '奖励',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].jl' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'bxkf',
                    align: 'center',
                    title: '保险扣费',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].bxkf' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'hj',
                    align: 'center',
                    title: '合计',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].hj' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'sxsf',
                    align: 'center',
                    title: '时薪实发',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='lwpqSxList[%s].sxsf' value='%s'>", index, value);
                        return html;
                    }
                },
            ]
        };
        $.table.init(options);
    });
    function addColumn_1() {
        var count = $("#bootstrap-table-1").bootstrapTable('getData').length;
        sub.editColumn();

        $("#bootstrap-table-1").bootstrapTable('insertRow', {
            index: count,
            row: {
                index: $.table.serialNumber(count),
                ffrq: "",
                sx: "",
                gs: "",
                qtxc: "",
                sfkc: "",
                jl: "",
                bxkf: "",
                hj: "",
                sxsf: "",

            }
        });
    }
    function addColumn() {
            var count = $("#bootstrap-table").bootstrapTable('getData').length;
            sub.editColumn();

            $("#bootstrap-table").bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                                ffrq: "",
                                jbgz: "",
                                jxgz: "",
                                sbjf: "",
                                jbf: "",
                                sfkc: "",
                                jl: "",
                                yxhj: "",
                                yxsf: "",
                }
            });
        }
</script>
</body>
</html>